package com.sirdc.modules.sys.web;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.JqGrid;
import com.sirdc.modules.sys.entity.SysLog;
import com.sirdc.modules.sys.filter.SysLogFilter;
import com.sirdc.modules.sys.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/modules/sys/syslog")
public class KeYanSysLogCtrl extends JsonBaseController {

    @Autowired
    private SysLogService logService;
    @Override
    protected String getView(String s) {
        return "/modules/sys/syslog/"+s;
    }


    @RequestMapping(method = RequestMethod.GET)
    public String initPage() {
        return getView("query");
    }

    /**
     * 输出json登录日志表
     *
     * @param filter
     * @return json
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST)
    public JqGrid query(@ModelAttribute SysLogFilter filter) {
        List<SysLog> query = logService.queryFilter(filter);
        return coverJqGrid(filter, query);
    }
}
